import fetch from 'common/src/utils/fetch';
import UTILS from "common/src/utils/utils";
// 根据工号查老师姓名
export function findNameByCode(data) {
  return fetch({
    url: '/api/studentservice/teacherInfo/findTeacherInfoBycode?code=' + data,
    method: 'get',
    headers: { 'Content-Type': 'application/json' }
  });
}

export function findList(data) {
  return fetch({
    url: '/api/majorservice/classPrivilege/list',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data
  });
}

export function add(data) {
  return fetch({
    url: '/api/majorservice/classPrivilege/add',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data
  });
}

export function edit(data) {
  return fetch({
    url: '/api/majorservice/classPrivilege/edit',
    method: 'put',
    headers: { 'Content-Type': 'application/json' },
    data
  });
}

export function deleteData(data) {
  return fetch({
    url: '/api/majorservice/classPrivilege/delete?id=' + data,
    method: 'delete',
    headers: { 'Content-Type': 'application/json' },
  });
}

export function getMajorByGrade(data) {
  return fetch({
    url: '/api/welcomeservice/tutorSchool/major/' + data,
    method: 'get',
    headers: { 'Content-Type': 'application/json' },
    data
  });
}

export function findCampusProfessionList(data) {
  return fetch({
    url: '/api/commonservice/campusProfession/findCampusProfessionList',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data
  });
}

export function getMajorByGradeAndTid(data) {
  return fetch({
    url: '/api/majorservice/classPrivilege/queryMajorByGidAndTid',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data
  });
}

export function getMajorListByUser(data) {
  return fetch({
    url: '/api/majorservice/classPrivilege/getMajorListByUser',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data
  });
}

// 文件导出，下载
export function downloadFile(url, fileName, fileType = 'application/vnd.ms-excel;charset=utf-8') {
  return fetch({
    url: url,
    method: 'get',
    responseType: 'blob'
  }).then(res => {
    UTILS.downloadFile(res, fileName, fileType);
  });
}
